package com.adtech.adms.commons.web.intercepter;

import java.util.Map;

import org.apache.log4j.Logger;

import com.adtech.adms.SessionKey;
import com.adtech.core.dao.query.QueryParams;
import com.adtech.core.web.action.BaseAction;
import com.opensymphony.xwork2.ActionInvocation;

/**
 * 
 * 
 * @author Dormin 
 * @since 2011-6-8 
 * 
 * @Copyright (C) AD Tech Workshop All Right Reserved
 */
public class BeforeFilterInterceptor extends BaseInterceptor {

	private static final long serialVersionUID = -6342795821580321655L;
	private static final Logger log = Logger.getLogger(BeforeFilterInterceptor.class);

	@Override
	public String intercept(ActionInvocation ai) throws Exception {
		Map<String, Object> params = super.getParameters(ai);
		Map<String, Object> session = super.getSession(ai);
		BaseAction action = (BaseAction) ai.getAction();
		processGridParameters(action, params, session);
		return ai.invoke();
	}

	@SuppressWarnings("unchecked")
	private void processGridParameters(BaseAction action, Map<String, Object> params, Map<String, Object> session) {
		Map<String, Object> statusMap = (Map<String, Object>) session.get(SessionKey.QUERY_STATUS);
		if (params.get(SessionKey.RESET_STATUS_FLAG)==null&&statusMap != null) {
			String key = action.getClass().getName();
			
			QueryParams saveParams = (QueryParams) statusMap.get(key);
			log.debug("saveParams is " + key + " " + saveParams );
			

		}
	}
}
